package com.zelin.web.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * ------------------------------
 * 功能：
 * 作者：WF
 * 微信：hbxfwf13590332912
 * 创建时间：2021/11/10-9:18
 * ------------------------------
 */
@WebFilter(urlPatterns = "/*")
public class MyFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("filter--->init()");
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("filter--->doFilter()");
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf8");
        filterChain.doFilter(req,resp);
    }

    @Override
    public void destroy() {
        System.out.println("filter--->destroy()");
    }
}
